package com.yyairmarkyy.arctool.layoutmanager;

import android.view.View;

import com.yyairmarkyy.arctool.layoutmanager.core.ViewPagerLayoutManager;


/**
 * Created by Dajavu on 12/7/16.
 */

public class CircleLayoutManager extends ViewPagerLayoutManager {

    private static int INTERVAL_ANGLE = 20;// The default interval angle between each items
    private static float DISTANCE_RATIO = 10f; // Finger swipe distance divide item rotate angle
    private static final int ITEM_ROATION_TAG = 100;

    private int mRadius;
    private int showNum;

    public CircleLayoutManager(int mRadius) {
        super();
        this.mRadius = mRadius ;
//        this.INTERVAL_ANGLE = intervalAngle;
    }

    public CircleLayoutManager(boolean shouldReverseLayout) {
        super(true);
    }


    /**
     * 内容顶点的半径
     * @param radius
     */
    public void setRadius(int radius){
        this.mRadius = radius;
    }

    @Override
    protected float setInterval() {
        return INTERVAL_ANGLE;
    }

    @Override
    protected void setUp() {
        startLeft = getHorizontalSpace();
        startTop = getVerticalSpace() - mRadius;
        offset = interval*showNum;
    }

    @Override
    protected float maxRemoveOffset() {
        return 0;
    }

    @Override
    protected float minRemoveOffset() {
        return -90;
    }

    @Override
    public float getBottomItemMinRadius() {
        return 90-(interval/2);
    }

    @Override
    protected int calItemLeftPosition(float targetOffset) {
        return (int) (mRadius * Math.cos(Math.toRadians(90 - targetOffset)));
    }

    @Override
    protected int calItemTopPosition(float targetOffset) {
        return (int) (mRadius - mRadius * Math.sin(Math.toRadians(90 - targetOffset)));
    }

    @Override
    protected void setItemViewProperty(View itemView, float targetOffset) {
        itemView.setTag(targetOffset);
    }

    @Override
    protected float propertyChangeWhenScroll(View itemView) {
        return (float) itemView.getTag();
    }

    @Override
    public float getDistanceRatio() {
        return DISTANCE_RATIO;
    }

    public  void setIntervalAngle(int intervalAngle) {
        INTERVAL_ANGLE = intervalAngle;
    }

    public static void setDistanceRatio(float distanceRatio) {
        DISTANCE_RATIO = distanceRatio;
    }

    public static int getIntervalAngle() {
        return INTERVAL_ANGLE;
    }

    public void setShowNum(int showNum) {
        this.showNum = showNum;
    }

    public int getmRadius() {
        return mRadius;
    }
}
